package com.chat.admin.controller;

import com.chat.admin.annotate.IsNumeric;
import com.chat.admin.domain.DTO.DisableAccountDTO;
import com.chat.admin.domain.DTO.UserDTO;
import com.chat.admin.domain.VO.UserVO;
import com.chat.admin.service.GroupService;
import com.chat.common.dto.DisableGroupDTO;
import com.chat.common.dto.GetGroupDTO;
import com.chat.common.form.ListForm;
import com.chat.common.vo.GetGroupVO;
import com.chat.common.vo.R;
import jakarta.validation.constraints.NotBlank;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 管理员操作群聊
 */
@RestController
@Validated
@RequestMapping("/admin/group")
public class GroupController {

    @Autowired
    GroupService groupService;

    /**
     * 条件获取群聊列表
     * @param getGroupDTO
     * @return
     */
    @PostMapping("/getGroupList")
    public R<ListForm<GetGroupVO>> getGroupList(@RequestBody GetGroupDTO getGroupDTO) {
        return groupService.getGroupList(getGroupDTO);
    }

    /**
     * 禁用群聊
     * @param
     * @return
     */
    @PostMapping("/disableGroup")
    public R DisableGroup(@RequestBody DisableGroupDTO disableGroupDTO) {
        return groupService.DisableGroup(disableGroupDTO);
    }

    /**
     * 启用群聊
     * @param ID
     * @return
     */
    @GetMapping("/enableGroup")
    public R<?> EnableGroup(@RequestParam @NotBlank(message = "ID不能为空") @IsNumeric(message = "ID不是数字") String ID){
        return groupService.EnableGroup(Long.valueOf(ID));
    }
}
